
/**
 * @Project : Clion_ProgrammingExercises
 * @File : 0788
 * @Author : WangRuoyu 
 * @Date : 2023/9/14 15:30
 */

#include "iostream"

using namespace std;

long long merge_sort(int a[], int l, int r) {
    if (l >= r) return 0;
    int mid = l + r >> 1;
    long long res = merge_sort(a, l, mid);
    res += merge_sort(a, mid + 1, r);
    int tmp[r - l + 1];

    int k = 0;
    int p = l;
    int q = mid + 1;

    while (p <= mid && q <= r) {
        if (a[p] <= a[q]) tmp[k++] = a[p++];
        else {
            tmp[k++] = a[q++];
            res += mid - p + 1;
        }
    }

    while (p <= mid) tmp[k++] = a[p++];
    while (q <= r) tmp[k++] = a[q++];

    for (int i = l, j = 0; i <= r; ++j, ++i) {
        a[i] = tmp[j];
    }

    return res;
}

int main() {
    int n;
    scanf("%d", &n);

    int a[n];
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
    }

    long long res = merge_sort(a, 0, n - 1);

    printf("%lld", res);

    return 0;
}